home *** CD-ROM | disk | FTP | other *** search
- # include "TransSkel.h"
- # include "TransDisplay.h"
-
- # include "FLMaca.h"
- # include "FLMapInfo.h"
- # include "FaceLift.h"
-
-
-
- static WindowPtr meterWind = nil;
- static WindowPtr helpWind = nil;
- static int hPara;
- static int errCount;
- static Str255 errWindName;
-
-
- /* ---------------------------------------------------------------- */
- /* General Display Window Routines */
- /* ---------------------------------------------------------------- */
-
-
- static pascal void
- DWindActivate (Boolean active)
- {
- WindowPeek w;
-
- if (!active) /* deactivated - was it closed? */
- {
- GetPort ((GrafPtr *) &w);
- if (w->visible == 0)
- {
- SkelRmveWind ((WindowPtr) w); /* yes - remove it */
- if ((WindowPtr) w == helpWind)
- helpWind = nil;
- }
- }
- FixMenus ();
- }
-
-
- /*
- * Build a display window. NewDWindow makes it the current output
- * window for display output. The window comes up in front unless
- * the meter is present, in which case it comes up under the meter.
- */
-
- void
- DisplayWindow (StringPtr title, Boolean visible)
- {
- WindowPtr w;
- Rect r;
- static int i = 0;
- int h, v;
-
- if (meterWind != nil && i < 1)
- i = 1;
- h = i * 23 + 5;
- v = h + 65;
- SetRect (&r, h, v, h + 350, v + 200);
- SetDWindowNotify (nil, DWindActivate);
- w = NewDWindow (&r, title, visible, (WindowPtr) -1L, true, 0L);
- if (visible)
- MakeFrontWind (w);
- if (++i == 4)
- i = 0;
- }
-
-
- /* ---------------------------------------------------------------- */
- /* Meter Window Routines */
- /* ---------------------------------------------------------------- */
-
-
- void
- MeterPos (int h, int lineNo)
- {
- SetPort (meterWind);
- MoveTo (h, (int) (lineNo * 16 + 14));
- }
-
-
- void
- MeterString (StringPtr s)
- {
- SetPort (meterWind);
- DrawString (s);
- }
-
-
- void
- MeterInt (int i)
- {
- Str255 s;
-
- NumToString ((int) i, s);
- MeterString (s);
- }
-
-
- void
- StartMeterParaInfo (int paras)
- {
- PenState p;
-
- MeterPos (5, 1);
- MeterString ("\pTotal Paragraphs: ");
- MeterInt (paras);
- MeterString ("\p Current: ");
- GetPenState (&p);
- hPara = p.pnLoc.h;
- }
-
-
- void
- SetMeterNum (int i)
- {
- MeterPos (hPara, 1);
- MeterInt (i);
- }
-
-
- void
- MeterErase (void)
- {
- SetPort (meterWind);
- EraseRect (&meterWind->portRect);
- }
-
-
- static pascal void
- MeterClobber (void)
- {
- DisposeWindow (meterWind);
- meterWind = nil;
- }
-
-
- void
- MeterBegin (void)
- {
- Rect r;
-
- SetRect (&r, 0, 0, 340, 36);
- if (SkelQuery (skelQHasColorQD))
- {
- meterWind = NewCWindow (nil, &r, "\p", false, dBoxProc,
- (WindowPtr) -1L, false, 0L);
- }
- else
- {
- meterWind = NewWindow (nil, &r, "\p", false, dBoxProc,
- (WindowPtr) -1L, false, 0L);
- }
- (void) SkelWindow (meterWind, nil, nil, nil, nil, nil, MeterClobber, nil, false);
- ValidRect (&meterWind->portRect);
- TextFont (0);
- TextSize (0);
- TextMode (srcCopy);
- SkelPositionWindow (meterWind, skelPositionOnParentDevice,
- FixRatio (1, 2), FixRatio (1, 10));
- MakeFrontWind (meterWind);
- }
-
-
- void
- MeterEnd (void)
- {
- SkelRmveWind (meterWind);
- }
-
-
- /* ---------------------------------------------------------------- */
- /* Error Window Routines */
- /* ---------------------------------------------------------------- */
-
-
- /*
- * Initialize an error window. This just clears the error count
- * and sets the name that will be given the window if an error
- * occurs. The window doesn't actually appear unless the error
- * message routine is called.
- */
-
- void
- ErrWindInit (StringPtr fName)
- {
- errCount = 0;
- CopyString (fName, errWindName);
- }
-
-
- void
- ErrWindMsge (StringPtr thing, int value)
- {
-
- if (!showBadFormats)
- return;
-
- if (errCount++ == 0) /* first error */
- {
- DisplayWindow (errWindName, true);
- }
- DisplayString (thing);
- DisplayShort (value);
- DisplayLn ();
- }
-
-
- /* ---------------------------------------------------------------- */
- /* Help Window Routines */
- /* ---------------------------------------------------------------- */
-
-
- /*
- * Create help window, unless it already exists - in which case
- * simply pull it to the front.
- */
-
-
- void
- HelpWindow (void)
- {
- Rect r;
- Handle h;
-
- if (helpWind == nil)
- {
- SetRect (&r, 40, 50, 450, 280);
- SetDWindowNotify (nil, DWindActivate);
- helpWind = NewDWindow (&r, "\pInformation Window", false, (WindowPtr) -1L, true, 0L);
-
- h = GetResource ('TEXT', helpTextNum); /* read help text */
- HLock (h); /* lock it and write to window */
- DisplayText (*h, GetHandleSize (h));
- HUnlock (h);
- ReleaseResource (h); /* done with it, so goodbye */
- SetDWindowPos (helpWind, 0); /* scroll back to top */
- SetDWindow (nil); /* no more output to this window */
- }
- MakeFrontWind (helpWind);
- }
-